package com.xyebank.cn.Mbean;



import com.xyebank.cn.entity.Banner;
import org.springframework.context.annotation.Bean;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedOperationParameter;
import org.springframework.jmx.export.annotation.ManagedOperationParameters;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.stereotype.Component;

import java.io.Serializable;

/**
 * 注册JMX Bean
 */
@ManagedResource(objectName ="com.xyebank.cn.Mbean.jmxBean:name=BannerMbean",description = "bannerJms管理")
@Component("BannerMbean")
public class BannerMbean implements Serializable {

    private String name;

    private String url;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    /**
     * Jmx注册方法
     * @param name
     * @param url
     * @return
     */
    @ManagedOperation
    @ManagedOperationParameters (value = {@ManagedOperationParameter(name = "url", description = "banner图地址"),
            @ManagedOperationParameter(name = "name",description = "banner名")})
    public Banner createBanner(String name, String url){
        Banner banner=new Banner();
        banner.setName(name);
        banner.setUrl(url);
        return banner;
    }
}
